@extends('admin.main')

@section('body')
    <div class="tab-wrap">
        <ul class="tab-nav nav">
            <li class="current"><a href="javascript:;">水票套餐库</a></li>
        </ul>
        <div class="tab-content">
            <!-- 访问授权 -->
            <div class="tab-pane in">
                <form action="" enctype="application/x-www-form-urlencoded"
                      method="POST" class="form-horizontal auth-form">
                    <dl class="checkmod">
                        <dt class="hd">
                            <label class="checkbox"><input class="auth_rules rules_all" type="checkbox"
                                                           >水票套餐列表
                            </label>
                        </dt>
                        <dd class="bd">
                            @if(count($rows))
                                <span class="child_row">
                                @foreach($rows as $v)
                                            <label class="checkbox">
                                                <input class="auth_rules" type="checkbox"
                                                       name="ids[]" @if(isset($info) && in_array($v['id'],$info['ids'])) checked @endif
                                                       value="{{$v['id']}}"/>{{$v['title']}}
                                            </label>

                                @endforeach
                                </span>
                            @endif
                        </dd>
                    </dl>
                    <input type="hidden" name="shop_id" value="{{$_GET['shop_id']}}"/>
                    <input type="hidden" name="id" value="{{isset($info) ? $info['id'] : 0}}"/>
                    <input type="hidden" name="old" value="{{isset($info) ? implode(',', $info['ids']) : 0}}"/>
                    <button type="submit" class="btn submit-btn ajax-post" target-form="auth-form">确 定</button>
                    <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
                </form>
            </div>

            <!-- 成员授权 -->
            <div class="tab-pane"></div>

            <!-- 分类 -->
            <div class="tab-pane"></div>
        </div>
    </div>

@endsection
@section('script')
    <script type="text/javascript" src="/static/qtip/jquery.qtip.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/qtip/jquery.qtip.min.css" media="all">
    <script type="text/javascript" charset="utf-8">
        +function ($) {
            {{--var rules = [{{$thisGroup['rules']}}];--}}
            {{--$('.auth_rules').each(function () {--}}
            {{--if ($.inArray(parseInt(this.value, 10), rules) > -1) {--}}
            {{--$(this).prop('checked', true);--}}
            {{--}--}}
            {{--if (this.value == '') {--}}
            {{--$(this).closest('span').remove();--}}
            {{--}--}}
            {{--});--}}

            //全选节点
            $('.rules_all').on('change', function () {
                $(this).closest('dl').find('dd').find('input').prop('checked', this.checked);
            });
            $('.rules_row').on('change', function () {
                $(this).closest('.rule_check').find('.child_row').find('input').prop('checked', this.checked);
            });

            $('.checkbox').each(function () {
                $(this).qtip({
                    content: {
                        text: $(this).attr('title'),
                        title: $(this).text()
                    },
                    position: {
                        my: 'bottom center',
                        at: 'top center',
                        target: $(this)
                    },
                    style: {
                        classes: 'qtip-dark',
                        tip: {
                            corner: true,
                            mimic: false,
                            width: 10,
                            height: 10
                        }
                    }
                });
            });

            $('select[name=group]').change(function () {
                location.href = this.value;
            });
        }(jQuery);
    </script>
@endsection
